/**
 * Logger is responsible for all printings in the firewall module.
 */

#ifndef _LOG_TRACE_H_
#define _LOG_TRACE_H_

#include <linux/netfilter.h>
#include <linux/kernel.h>
#include "ipt_ipcontext.h"

/********** MESSAGE CONTEXTS ***********/

/**
 * Messages types for report to user.
 */
enum msg_ctxt { 
    MSG_GENERAL,
    MSG_CTXT_NUM
};

/* Decision for the package */
enum package_status { 
    PACKAGE_ACCEPT,
    PACKAGE_DENY,
    PACKAGE_STATUS_NUM   
};

/* Messages types names for report to user */
extern char *msg_ctxt_name[MSG_CTXT_NUM+1];
/* Messages on/off flags */
extern int msg_mask[MSG_CTXT_NUM];

/********** MESSAGE OUTPUT ***********/

/* Constant string for user reports */
#define IDENTIFIER "IPcontext OSLFW: "

/* Macro for error reports */		
#define OUT_ERROR(fmt, args...)						\
		printk(KERN_ERR "IPcontext error: " fmt "\n", ##args);		

/* Macro for debug reports */		
#ifdef __DEBUG__
#define OUT_DEBUG(fmt, args...)  						\
		printk(KERN_DEBUG "IPcontext info: " fmt "\n", ##args); 	
#else
#define OUT_DEBUG(fmt, args...)
#endif
	
/* Macro for general reports */		
#define OUT_INFO(fmt, args...)  						\
		printk(KERN_INFO "IPcontext info: " fmt "\n", ##args);  

/* Macro for reports to user */
#define OUT_GEN(ctxt, fmt, args...)					\
		if(msg_mask[ctxt])					\
        	  printk(KERN_DEBUG IDENTIFIER fmt "\n", ##args); 	

/********** MESSAGE FUNCTIONS ***********/
/* Enables the given message type */
int msg_enable(enum msg_ctxt ctxt);
/* Disables the given message type */
int msg_disable(enum msg_ctxt ctxt);
/* Enables/Disables all messages types */
int msg_change_all(int enable);
/* Reports to user the given data */
void log_session(enum package_status p,  struct ipt_context_info *info,
                          const struct net_device *in,
                          const struct net_device *out,
                          const struct sk_buff *skb);

#endif /*_LOG_TRACE_H_*/
